﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;
using System.Collections.ObjectModel;

namespace Portal.Systems.Model
{
    public class DataLanguageCls
    {
        public string DataLanguageId;
        public string AssetCode;
        public string DataLanguage;
        public string Subject;
    }

    public class DataLanguageParser
    {
        public static DataLanguageCls CreateInstance()
        {
            //tao 1 class trang....
            DataLanguageCls oDataLanguageCls = new DataLanguageCls();
            return oDataLanguageCls;
        }

        public static DataLanguageCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            DataLanguageCls oDataLanguageCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oDataLanguageCls;
        }


        public static DataLanguageCls ParseFromDataRow(DataRow dr)
        {
            DataLanguageCls ODataLanguageCls = new DataLanguageCls();
            ODataLanguageCls.DataLanguageId = XmlUtility.GetString(dr, "DataLanguageId", true);
            ODataLanguageCls.AssetCode = XmlUtility.GetString(dr, "AssetCode", true);
            ODataLanguageCls.DataLanguage = XmlUtility.GetString(dr, "DataLanguage", true);
            ODataLanguageCls.Subject = XmlUtility.GetString(dr, "Subject", true);

            return ODataLanguageCls;
        }

        public static DataLanguageCls[] ParseFromDataTable(DataTable dtTable)
        {
            DataLanguageCls[] DataLanguages = new DataLanguageCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                DataLanguages[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return DataLanguages;
        }
    }
}


